package com.mavenq.fly.config;

import com.mavenq.fly.filter.SqlStatsFilter;
import com.mavenq.fly.interceptor.SqlStatsInterceptor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisConfig {
    
    @Bean
    public SqlStatsInterceptor sqlStatsInterceptor() {
        return new SqlStatsInterceptor();
    }
    
    @Bean
    public FilterRegistrationBean<SqlStatsFilter> sqlStatsFilter() {
        FilterRegistrationBean<SqlStatsFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new SqlStatsFilter());
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}